<?php

/**
 * 前台项目基类
 * 
  + -----------------------------------------------------
 * Date 2013-3-8
  + -----------------------------------------------------
 */
class BaseAction extends CommonAction {

    function _initialize() {
        parent::_initialize();
        $this->assign("base_header", APP_PATH . 'Modules/Home/Tpl/Public/header.php');
        $this->assign("base_footer", APP_PATH . 'Modules/Home/Tpl/Public/footer.php');
        
        //底部文章
        $article_footer = M('Article')->where(array('status'=>1))->limit(10)->select();
        $article_header = M('Article')->where(array('status'=>1))->limit(10,12)->select();
        $this->assign('article_footer', $article_footer);
        $this->assign('article_header', $article_header);
    }

    /**
     * 生成SEO
     * @param $title        标题
     * @param $description  描述
     * @param $keyword      关键词
     */
    function seo($title = '', $description = '', $keyword = '') {
        if (!empty($title))
            $title       = strip_tags($title);
        if (!empty($description))
            $description = strip_tags($description);
        if (!empty($keyword))
            $keyword     = str_replace(' ', ',', strip_tags($keyword));

        $seo['site_title']  = C("site_title");
        $seo['keyword']     = !empty($keyword) ? $keyword : C("site_keyword");
        $seo['description'] = isset($description) && !empty($description) ? $description : (C("site_description") != "" ? C("site_description") : '');
        $seo['title']       = (isset($title) && !empty($title) ? $title . ' - ' : '');
        foreach ($seo as $k => $v) {
            $seo[$k] = str_replace(array("\n", "\r"), '', $v);
        }
        $this->assign("SEO", $seo);
    }

}

?>